package other.getech.oa.service.impl;

import com.rkhd.platform.sdk.creekflow.approvalevent.ApprovalEventRequest;
import com.rkhd.platform.sdk.creekflow.approvalevent.ApprovalEventResponse;
import com.rkhd.platform.sdk.exception.ApiEntityServiceException;
import com.rkhd.platform.sdk.exception.XsyHttpException;
import com.rkhd.platform.sdk.log.Logger;
import com.rkhd.platform.sdk.log.LoggerFactory;
import other.getech.oa.service.OAService;
import other.getech.oa.service.abstracts.AbstractApprovalEvent;

/**
 * 需求:节点同意后将OA待办设置为已办
 */
public class CommonAgreeImpl extends AbstractApprovalEvent {

    private static final Logger logger = LoggerFactory.getLogger();

    @Override
    public ApprovalEventResponse execute(ApprovalEventRequest request) {
        logger.info(String.format("(entityApiKey:%s,dataId:%s,usertaskLogId:%s)节点同意后", request.getEntityApiKey(), request.getDataId(), request.getUsertaskLogId()));

        try {
            new OAService().agree(request.getEntityApiKey(), request.getDataId(), request.getUsertaskLogId());
        } catch (ApiEntityServiceException | XsyHttpException e) {
            throw new RuntimeException(e);
        }

        return resp(true, null);
    }

    public static void main(String[] args) {
    }
}

